package fristphase.day9_04.submarinegametest01;

import javax.swing.*;
import java.awt.*;

public class World extends JPanel {
    private final static int WIDTH = 614;
    private final static int HEIGHT = 479;

    private BattleShip ship = new BattleShip();

    private SeaObject[] submarines = {
            new ObserveSubmarine(1),
            new MineSubmarine(1),
            new TorpedoSubmarine(1),
    };

    private Mine[] mines = {
            new Mine(100, 200, 1),
    };

    private Bomb[] bombs = {
            new Bomb(200, 300, 1),
    };

    public void paint(Graphics g) {
        Images.sea.paintIcon(null, g, 0, 0);
        ship.paintImage(g);
        for (int i = 0; i < submarines.length; i++) {
            submarines[i].paintImage(g);
        }
        for (int i = 0; i < mines.length; i++) {
            mines[i].paintImage(g);
        }
        for (int i = 0; i < bombs.length; i++) {
            bombs[i].paintImage(g);
        }
    }

    public static void main(String[] args) {
        JFrame frame = new JFrame();
        World world = new World();
        frame.add(world);
        world.setFocusable(true);

        frame.setSize(WIDTH + 16, HEIGHT + 39);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLocationRelativeTo(null);
        frame.setResizable(false);
        frame.setVisible(true);
    }
}











